<!DOCTYPE html>
<title>ClipboardEvent constructor</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id="drag" draggable="true">Drag Me</div>

<script>
test(function() {
  assert_equals(new ClipboardEvent('type').clipboardData, null);
}, 'ClipboardEvent constructor without a dictionary');

test(function() {
  assert_equals(
      new ClipboardEvent(
        'type',
        { dataType: 'dataType', data: 'data' })
      .clipboardData,
      null);
}, 'ClipboardEvent constructor with dictionary where optional attribute clipboardData is omitted');

async_test(function() {
  var dragTarget = document.getElementById("drag");
  dragTarget.addEventListener("drag", this.step_func_done(function(e) {
    var clipboardData = e.dataTransfer;
    e.preventDefault();
    assert_equals(
        new ClipboardEvent(
          'type',
          { dataType: 'dataType', data: 'data', clipboardData: clipboardData})
        .clipboardData, clipboardData);
  }));

  if (window.eventSender) {
    eventSender.dragMode = true;
    eventSender.mouseMoveTo(drag.offsetLeft + 10, drag.offsetTop + 5);
    eventSender.mouseDown();
    eventSender.mouseMoveTo(drag.offsetLeft + 10, drag.offsetTop + 30)
    eventSender.mouseUp();
  }
}, 'ClipboardEvent constructor with dictionary where optional attribute clipboardData is passed');
</script>
